package com.edisoncgh.service.impl;


import com.edisoncgh.dao.ViewMapper;
import com.edisoncgh.pojo.View;
import com.edisoncgh.pojo.ViewExample;
import com.edisoncgh.service.ViewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ViewServiceImpl implements ViewService {
    private ViewMapper viewMapper;

    @Autowired
    public void setViewMapper(ViewMapper viewMapper){
        this.viewMapper = viewMapper;
    }
    @Override
    public List<View> findAll() {
        ViewExample viewExample = new ViewExample();
        return viewMapper.selectByExample(viewExample);
    }

    @Override
    public List<View> findByClassNo(String classNo) {
        Integer c = Integer.valueOf(classNo);
        ViewExample viewExample = new ViewExample();
        viewExample.createCriteria()
                .andClassNoEqualTo(c);
        return viewMapper.selectByExample(viewExample);
    }

    @Override
    public List<View> findByBookClassNo(String classNo) {
        Byte c = Byte.valueOf(classNo);
        ViewExample viewExample = new ViewExample();
        viewExample.createCriteria()
                .andBookClassNoEqualTo(c);
        return viewMapper.selectByExample(viewExample);
    }
}
